
//线段切割法
function lineCut(person,total){
    var points=[];
    var packets=[]
    while(points.length<(person-1)){
        var num=((Math.random()*total*100+1)/100).toFixed(3)
        num=Number(num.slice(0,num.length-1))
        if(!points.includes(num))
        points.push(num)
    }
    
    
    points=points.sort((a,b)=>a-b)
    console.log(points)
    console.log('===================')
    var proPoint=0;
    var fl=0;
    for(var i=0;i<points.length;i++){
        var range=((Number(points[i]*100)-Number(proPoint*100))/100).toFixed(3)
        range=Number(range.slice(0,range.length-1))
        fl=((Number(fl)*100+Number(range)*100)/100).toFixed(3)
        fl=Number(fl.slice(0,fl.length-1))
        proPoint=points[i]
        packets.push(range)
    }
    var lastNum=((Number(total*100)-Number(fl*100))/100).toFixed(3)
    lastNum=Number(lastNum.slice(0,lastNum.length-1))
    packets.push(lastNum)
    return packets
}
var result=lineCut(10,100)
console.log(result)